#include "FontTest.h"

using namespace CAIG;
using namespace DKGL;

bool FontTest::init()
{
	return (CWin::init());
}

void FontTest::OnCreate()
{
	CreateDKGLContext(hDC);
	//ErrorHandler::GetSingleton().clear();

	//g_FontMgr.addNewFont("Default", hDC);
	g_FontMgr.addNewFont("Arial_20", hDC, "Arial",20, FT_NORMAL ,FALSE);
	g_FontMgr.addNewFont("TNR_40_B", hDC, "Times New Roman", 40, FT_BOLD);
	g_FontMgr.addNewFont("Arial_B_40_I", hDC, "Arial Black", 40, FT_NORMAL, TRUE);

	g_FontMgr.setFontColor("TNR_40_B", 1.0f, 0.0f, 0.0f);
}
void FontTest::OnPaint()
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	g_FontMgr.begin(g_ViewportMgr.getViewport(0));
	g_FontMgr.printf("Default", mWndWidth/2, mWndHeight*0.2);//,
		//DKGL::MA_ALIGN2LEFT, "Default");
	g_FontMgr.printf("Test2", mWndWidth/2,  mWndHeight*0.4, 
		DKGL::MA_ALIGN2CENTER, "TNR_40_B");
	//g_FontMgr.printf("TNR_40_B", mWndWidth/2,  mWndHeight*0.6, 
	//	DKGL::MA_ALIGN2RIGHT, "Test3");
	//g_FontMgr.printf("Arial_B_40_I", mWndWidth/2,  mWndHeight*0.8, 
	//	DKGL::MA_ALIGN2RIGHT, "Test4");

	g_FontMgr.end();

}
void FontTest::OnSize(WORD width, WORD height)
{
	intRect2D rc;
	rc.x = 0;
	rc.y = 0;
	rc.width = width;
	rc.height = height;

	g_ViewportMgr.getViewportPtr(0)->onSize(rc, DKGL::DefaultVpSizer());
}

void FontTest::OnTime()
{

}